import React, { Component } from 'react'

let Show = ({ lastName, firstName }) => (
    <h1>
        {firstName} - {lastName}
    </h1>
)

const WithName = Comp => {
    class NewComp extends Component {
        componentDidMount() {
            // 采集用户行为
            console.log('post 用户访问到了 xx 页面')
        }
        render() {
            return (
                <Comp 
                    {...this.props}
                    firstName={'xinglong'}
                />
            )
        }
    }
    return NewComp
}

Show = WithName(Show)

export default class Hoc extends Component {
    render() {
        return (
            <div>
                Hoc
                <Show lastName=".shi" />
            </div>
        )
    }
}
